import apiClient from '@/api/axios.js';

export class ReportRecordApi {

  // 查询所有举报记录
  static async getAllReportRecords() {
    try {
      const response = await apiClient.get('/reportRecord');
      return response.data;
    } catch (error) {
      throw new Error(error.message);
    }
  }

  // 根据 reportID 查询举报记录
  static async getReportRecordById(reportID) {
    try {
      const response = await apiClient.get(`/reportRecord/${reportID}`);
      return response.data;
    } catch (error) {
      throw new Error(error.message);
    }
  }

  // 根据 reporterID 和 reporteeID 查询举报记录
  static async getReportRecordsByReporterAndReportee(reporterID, reporteeID) {
    try {
      const response = await apiClient.get(`/reportRecord/reporter/${reporterID}/reportee/${reporteeID}`);
      return response.data;
    } catch (error) {
      throw new Error(error.message);
    }
  }

  // 新增举报记录
  static async createReportRecord(params) {
    const { reporterID, reporteeID, reportType, reportReason, handlingResult, submissionTime, handlingTime, reportStatus } = params;
    try {
      const response = await apiClient.post('/reportRecord', {
        reporterID,
        reporteeID,
        reportType,
        reportReason,
        handlingResult,
        submissionTime,
        handlingTime,
        reportStatus
      });
      return response.data;
    } catch (error) {
      throw new Error(error.message);
    }
  }

  // 更新举报记录
  static async updateReportRecord(reportID, params) {
    const { reporterID, reporteeID, reportType, reportReason, handlingResult, submissionTime, handlingTime, reportStatus } = params;
    try {
      const response = await apiClient.put(`/reportRecord/${reportID}`, {
        reporterID,
        reporteeID,
        reportType,
        reportReason,
        handlingResult,
        submissionTime,
        handlingTime,
        reportStatus
      });
      return response.data;
    } catch (error) {
      throw new Error(error.message);
    }
  }

  // 删除举报记录
  static async deleteReportRecord(reportID) {
    try {
      const response = await apiClient.delete(`/reportRecord/${reportID}`);
      return response.data;
    } catch (error) {
      throw new Error(error.message);
    }
  }
}
